package com.林子祺.CAT旅游系统.view.tour.search;

import com.林子祺.CAT旅游系统.controller.contentmanagement.AbstractSearch;
import com.林子祺.CAT旅游系统.view.Menu;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class SearchTable {

    public static void search(){
        JFrame jf = new JFrame("查找");
        jf.setSize(200, 200);
        jf.setLocationRelativeTo(null);
        jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        JPanel panel = new JPanel();

        // 创建文本框，指定可见列数为8列
        final JTextField textField = new JTextField(8);
        textField.setFont(new Font(null, Font.PLAIN, 20));
        panel.add(textField);

        // 创建一个按钮，点击后获取文本框中的文本
        JButton btn = new JButton("提交");
        btn.setFont(new Font(null, Font.PLAIN, 20));
        btn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                AbstractSearch.search("name",textField.getText());
                jf.dispose();
            }
        });
        panel.add(btn);

        JButton btn1 = new JButton("返回");
        btn1.setFont(new Font(null, Font.PLAIN, 20));
        btn1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    Menu.menu();
                } catch (AWTException ex) {
                    throw new RuntimeException(ex);
                }
                jf.dispose();
            }
        });
        panel.add(btn1);

        jf.setContentPane(panel);
        jf.setVisible(true);

    }

}
